<?php
	//跨域被请求必须加,冒号后面代表请求的网站网址,*代表任何网站都可以跨域请求该php页面的数据
	header("Access-Control-Allow-Origin:*");
	include('include/config.php');
	$user = $_POST['user'];
	$password = $_POST['password'];
	include('include/rsa.php');
	include('include/returnParameters.php');
/*
	$rsauser = '';
	$rsapassword = "";	
	// 公钥加密方法
	openssl_public_encrypt($user,$rsauser,$pu_key);//公钥加密
	// 参数1 原数据
	// 参数2 加密后存放的变量
	// 参数3 rsa验证可用后的密匙
*/
	
	$userInfo = rsaInfo($user, $password);
	$userName = $userInfo['user'];
	$sql="select * from users WHERE phone='$userName'";
	$mysqlInfo=get_all($sql);
	if ($mysqlInfo[0]['phone'] == $userInfo['user']){
		if($mysqlInfo[0]['password'] == $userInfo['password']){
			$isMessage = '登录成功';
			$data = login($userInfo, $isMessage);
			echo json_encode($data);exit();
		} else {
			$code = 2;
			$isMessage = '密码错误';
			$data = commonparameters($isMessage, $code);
			echo json_encode($data);exit();
		}
	} else {
		$isMessage = '用户不存在';
		$code = 1;
		$data = commonparameters($isMessage, $code);
		echo json_encode($data);exit();
	}
	









?>